﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Direct.Mvc;
using System.Web.Mvc;
using Direct.Server.Modules.SysAdmin.SystemInfo.Views;
using Direct.Modularity;

namespace Direct.Server.Modules.SysAdmin.SystemInfo.Controllers
{
    public class SysInfoController : ServerControllerBase
    {
        public ActionResult AssemblyView()
        {
            ViewData["assemblies"] = AppDomain.CurrentDomain.GetAssemblies().Select(asm => asm.FullName).ToArray();
            return View<SysInfoAssembliesView>();
        }

        public ActionResult ModulesView()
        {
            var catalogService = ServiceLocator.GetInstance<IModuleCatalog>();
            ViewData["modules"] = catalogService.Modules.Select(m => new
            {
                Module = m,
                DependsOn = catalogService.GetDependentModules(m).ToArray(),
                Dependents = catalogService.GetDependencyModules(m).ToArray()
            }).ToArray();
            return View<SysInfoModulesView>();
        }
    }
}
